package com.itheima.d5_resource;

import java.io.*;

/*
     目标：掌握释放资源的方式：try-with-resource
 */
public class Test3 {
    public static void main(String[] args) {
        try (FileInputStream file1 = new FileInputStream("D:\\Desktop\\1123.txt");
             FileOutputStream file2 = new FileOutputStream("E:\\1123d\\112.txt");
        ) {

            int len;
            byte[] buffer = new byte[1024];
            while ((len = file1.read(buffer)) != -1) {
                file2.write(buffer, 0, len);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
